package com.corticon.dialogs.util.security;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.GrantedAuthority;
import org.springframework.security.userdetails.User;

/**
 *
 * @author Lifan Yang
 */
public class CustomUserDetailsImpl extends User implements CustomUserDetails {

    private String groupName;
    private GrantedAuthority[] authorities;
    private List<String> permissions = new ArrayList<String>();

    public CustomUserDetailsImpl(String username, String password, boolean enabled,
        boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked,
        GrantedAuthority[] authorities, String groupName) {
        super(username, password, enabled, accountNonExpired, credentialsNonExpired,
            accountNonLocked, authorities);
        setGroupName(groupName);
        setAuthorities(authorities);
    }

    @Override
    public String getGroupName() {
        return groupName;
    }

    @Override
    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    @Override
    public GrantedAuthority[] getAuthorities() {
        return authorities;
    }

    @Override
    public void setAuthorities(GrantedAuthority[] authorities) {
        this.authorities = authorities;
    }

    @Override
    public List<String> getPermissions() {
        return permissions;
    }

    @Override
    public void setPermissions(List<String> permissions) {
        this.permissions = permissions;
    }

    @Override
    public String toString() {
        return this.getUsername();
    }
}
